﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PRE.Catalog
{
    public partial class frmNCC_loads : DevExpress.XtraEditors.XtraForm
    {
        DAL.Entities_DAL.NCC_DAL _dal = new DAL.Entities_DAL.NCC_DAL();
        BLL.Entities_BLL.Xu_ly_chung _chung = new BLL.Entities_BLL.Xu_ly_chung();

        public frmNCC_loads()
        {
            InitializeComponent();
        }

        private void frmNCC_loads_Load(object sender, EventArgs e)
        {

        }

        private void cmdLuu_Click(object sender, EventArgs e)
        {
            var name = _chung.Proper(txtTenncc.Text);
            var _dc = _chung.Proper(txtDC.Text);

            var o = new DAL.Entities.NHA_CC()
            {
                MA_NCC = txtMancc.Text,
                D_CHI = _dc,
                TEN_NCC = name,

            };

            var oki = _dal.Insert(o);
            if (oki)
            {
                MessageBox.Show("Đã lưu thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Lỗi! Lưu thất bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }

        private void cmdLammoi_Click(object sender, EventArgs e)
        {
            txtMancc.Text = null;
            txtTenncc.Text = null;
        }

        private void cmdThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }

      
    }
}
